home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 July: Mac OS SDK / Dev.CD Jul 96 SDK / Dev.CD Jul 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / ODFDev / ODF / Framewrk / FWPart / Include / FWPart.h < prev    next >
Encoding:
Text File  |  1996-04-25  |  16.4 KB  |  498 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWPart.h
  4. //    Release Version:    $ ODF 1 $
  5. //
  6. //    Copyright:            (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #ifndef FWPART_H
  11. #define FWPART_H
  12.  
  13. #ifndef FWEVENTH_H
  14. #include "FWEventH.h"
  15. #endif
  16.  
  17. #ifndef FWPRTDEF_H
  18. #include "FWPrtDef.h"
  19. #endif
  20.  
  21. #ifndef FWWINDOW_H
  22. #include "FWWindow.h"
  23. #endif
  24.  
  25. // ----- Foundation Includes -----
  26.  
  27. #ifndef FWPSTR_H
  28. #include "FWPStr.h"
  29. #endif
  30.  
  31. #ifndef FWTCOLL_H
  32. #include "FWTColl.h"
  33. #endif
  34.  
  35. // ----- OpenDoc Includes -----
  36.  
  37. #ifndef SOM_ODPart_xh
  38. #include <Part.xh>
  39. #endif
  40.  
  41. //========================================================================================
  42. //    Forward Declarations
  43. //========================================================================================
  44.  
  45. class ODFrame;
  46. class ODWindow;
  47. class ODSession;
  48. class ODDraft;
  49.  
  50. class FW_CFrame;
  51. class FW_CSelection;
  52. class FW_CPoint;
  53. class FW_CMenuBar;
  54. class FW_CEventDispatcher;
  55. class FW_CCommand;
  56. class FW_CPrivOrderedCollection;
  57. class FW_CCloneInfo;
  58. class FW_CPullDownMenu;
  59. class FW_CWindow;
  60. class FW_CPresentation;
  61. class FW_CExtensionManager;
  62. class FW_CLinkManager;
  63. class FW_CIdler;
  64. class FW_CSemanticInterface;
  65.  
  66. class FW_CPrintInfo;
  67. class FW_CPresentationCollection;
  68. class FW_CContent;
  69. class FW_CDataInterchange;
  70.  
  71. //========================================================================================
  72. //    class FW_CPart
  73. //========================================================================================
  74.  
  75. class FW_CPart : public FW_MEventHandler
  76. {
  77.     friend class ODFModule_FW_SOMPart;
  78.     friend class FW_CPartPresentationIterator;
  79.     friend class FW_CPartFrameIterator;
  80.     friend class FW_CPartLinkSourceIterator;
  81.     friend class FW_CPartLinkDestIterator;
  82.     friend class FW_CIdler;
  83.     
  84. public:
  85.     FW_DECLARE_CLASS
  86.     FW_DECLARE_AUTO(FW_CPart)
  87.  
  88. //----------------------------------------------------------------------------------------
  89. //    Initialization/Destruction
  90. //
  91. public:
  92.     FW_CPart(ODPart* odPart, 
  93.              FW_Instance partInstance, 
  94.              FW_ResourceId partInfoID);
  95.     
  96.     virtual void                 Initialize(Environment *ev);
  97.     virtual                     ~FW_CPart();
  98.  
  99. //----------------------------------------------------------------------------------------
  100. //    Inherited from FW_MEventHander
  101. //
  102. public:
  103.     virtual FW_Boolean                HandleAdjustMenus(Environment *ev, 
  104.                                         FW_CMenuBar* menuBar,
  105.                                         FW_Boolean hasMenuFocus,
  106.                                         FW_Boolean isRoot);
  107.  
  108. //----------------------------------------------------------------------------------------
  109. //    New API
  110. //
  111. public:    
  112.     //--------------------------------------------------------------------------
  113.     // method from ODPart
  114.     ODStorageUnit*                    GetStorageUnit(Environment *ev) const;
  115.  
  116.     virtual void                    Release(Environment *ev);
  117.     virtual void                    ReleaseAll(Environment *ev);
  118.     
  119.     FW_Boolean                        GetPartName(Environment *ev, FW_CString& partName) const;
  120.         // Returns true if the part has a name. Returns false otherwise and partName is
  121.         // then set to the name in the partInfo resource
  122.     
  123.     virtual ODSize                    Purge(Environment *ev, ODSize size);
  124.                                     
  125.     //--------------------------------------------------------------------------
  126.     // Draft
  127.  
  128.     virtual FW_Boolean                IsReadOnly(Environment* ev) const;
  129.     ODDraft*                        GetDraft(Environment* ev) const;
  130.     
  131.     //--------------------------------------------------------------------------
  132.     // Presentation
  133.  
  134.     FW_CPresentation*                RegisterPresentation(Environment *ev, 
  135.                                         ODType presentationType, 
  136.                                         FW_Boolean defaultPresentation,
  137.                                         FW_CSelection* selection = NULL);
  138.     virtual FW_CPresentation*        ValidatePresentation(Environment *ev,
  139.                                         FW_CPresentation* presentation,
  140.                                         FW_Boolean isRootFrame) const;
  141.     FW_CPresentation*                FindPresentation(Environment *ev, 
  142.                                         ODTypeToken presentationType) const;
  143.  
  144.     //--------------------------------------------------------------------------
  145.     // Document Window Creation
  146.  
  147.     virtual FW_CWindow*             NewDocumentWindow(Environment* ev);
  148.     
  149.     //--------------------------------------------------------------------------
  150.     // Frame 
  151.  
  152.     virtual FW_CFrame*                 NewFrame(Environment *ev,
  153.                                         ODFrame* odFrame, 
  154.                                         FW_CPresentation* presentation,
  155.                                         FW_Boolean fromStorage) = 0;
  156.     
  157.     FW_Boolean                        IsValidDisplayFrame(Environment *ev, 
  158.                                         ODStorageUnitID displayFrameID) const;
  159.     
  160.     FW_Boolean                        HasSelectionFocus(Environment *ev) const;
  161.  
  162.     //--------------------------------------------------------------------------
  163.     // Menus
  164.  
  165.     virtual void                     InstallMenus(Environment *ev, FW_CMenuBar* menuBar);
  166.             
  167.     //--------------------------------------------------------------------------
  168.     // Getters/Setters
  169.  
  170.     ODPart*                         GetODPart(Environment *ev) const;
  171.     
  172.     FW_CFrame*                         GetLastActiveFrame(Environment *ev) const;
  173.                                     
  174.     ODFacet*                         GetActiveFacet(Environment *ev) const;
  175.     
  176.     FW_CMenuBar*                     GetMenuBar(Environment *ev) const;
  177.     
  178.     unsigned long                    CountDisplayFrame(Environment *ev) const;
  179.     
  180.     ODSession*                         GetSession(Environment *ev) const;
  181.     
  182.     ODValueType                        GetPartKind(Environment *ev) const;
  183.     
  184.     FW_Instance                        GetPartInstance(Environment *ev) const;
  185.     FW_ResourceId                    GetViewAsIconID(Environment *ev) const;
  186.  
  187.     FW_CEventDispatcher*            GetEventDispatcher(Environment *ev) const;
  188.     
  189.     void                            SetPrintInfo(FW_CPrintInfo* printInfo);
  190.     FW_CPrintInfo*                    GetPrintInfo() const;
  191.     
  192.     //--------------------------------------------------------------------------
  193.     // Change
  194.  
  195.     void                            Changed(Environment *ev);
  196.         
  197.     //--------------------------------------------------------------------------
  198.     // Linking
  199.  
  200.     virtual FW_CLinkManager*         NewLinkManager(Environment* ev);
  201.     FW_CLinkManager*                GetLinkManager(Environment* ev) const;
  202.  
  203.     virtual void                    LinkStatusChanged(Environment *ev, ODFrame* odFrame);
  204.  
  205.     //--------------------------------------------------------------------------
  206.     // Externalize/Internalize Content
  207.  
  208.     virtual FW_CContent*            NewPartContent(Environment* ev) = 0;
  209.     
  210.     virtual void                    ExternalizeContent(Environment *ev,
  211.                                         ODStorageUnit* storageUnit,
  212.                                         FW_CCloneInfo* cloneInfo);
  213.         // Should never have to be overriden. Use your content object instead                            
  214.     virtual void                    InternalizeContent(Environment *ev,
  215.                                         ODStorageUnit* storageUnit, 
  216.                                         FW_CCloneInfo* cloneInfo);
  217.         // Should never have to be overriden. Use your content object instead                            
  218.  
  219.     virtual void                     AddProperties(Environment *ev, ODStorageUnit* storageUnit);
  220.         // Override AddProperties to add other properties/values than the standard 
  221.         // kODContentProperty/partKind
  222.     virtual void                    ClearPartStorage(Environment* ev, ODStorageUnit* storageUnit);
  223.         // Override ClearPartStorage if your are supporting other value than the standard partKind or
  224.         // your don't want the partKind value to be cleared before each externalize
  225.     virtual FW_Boolean                IsValidContentValue(Environment* ev, ODType type);
  226.         // Override if your part support more than the standard partKind value. The default implementation
  227.         // will remove all value not equal to partKind
  228.         
  229.     FW_CContent*                    GetContent(Environment* ev) const;
  230.     FW_CDataInterchange*            GetDataInterchange(Environment* ev) const;
  231.  
  232.     //--------------------------------------------------------------------------
  233.     // Commands
  234.  
  235.     ODTranslateResult            TranslateData(Environment* ev, 
  236.                                     ODStorageUnit* storageUnit,
  237.                                     ODType translateKind,
  238.                                     ODType desiredKind);
  239.  
  240.     //--------------------------------------------------------------------------    
  241.     // Extensions
  242.     
  243.     FW_CExtensionManager*         GetExtensionManager(Environment *ev) const;
  244.     
  245.     //--------------------------------------------------------------------------    
  246.     // Scripting
  247.     
  248.     FW_CSemanticInterface*         GetSemanticInterface(Environment *ev) const;
  249.  
  250. //----------------------------------------------------------------------------------------
  251. //    Internal API (you should never have to called it)
  252. //
  253. public:
  254.     virtual void                    PrivSetLastActiveFrame(FW_CFrame* lastActiveFrame);
  255.     void                            PrivEnableMenuBar(Environment *ev, FW_Boolean enable, FW_Boolean appleMenu);
  256.     
  257.     // ----- Presentation Management -----
  258.     FW_CPresentation*                PrivGetPresentation(Environment *ev, ODFrame* odFrame) const;
  259.     void                            PrivAddPresentation(FW_CPresentation* presentation);
  260.     void                            PrivRemovePresentation(FW_CPresentation* presentation);
  261.     
  262.     // ----- Cloning -----
  263.     virtual void                    PrivCloneInto(Environment *ev,
  264.                                             ODDraftKey key,
  265.                                             ODStorageUnit* toSU,
  266.                                             ODFrame* scope);
  267.  
  268.     // ----- Idle Management -----
  269.     void                            PrivCountIdleRegistering(FW_Boolean registering);
  270.     
  271.     // ----- Session Globals -----
  272.     void                            PrivInitGlobals(Environment *ev);
  273.     void                            PrivReleaseGlobals();
  274.     
  275.     // ----- Presentation Factory -----
  276.     virtual FW_CPresentation*        PrivNewPresentation(Environment *ev, 
  277.                                             FW_CSelection* selection,
  278.                                             ODTypeToken presentationType);
  279.                                             
  280.     // ----- Data Interchanged Factory -----
  281.     virtual FW_CDataInterchange*     PrivNewDataInterchange(Environment* ev);
  282.  
  283.     // ----- Event Dispatcher Factory -----
  284.     virtual FW_CEventDispatcher*    PrivNewEventDispatcher(Environment *ev);
  285.  
  286.     // ----- Content Property cleaning -----
  287.     void                            PrivCleanseContentProperty(Environment* ev, 
  288.                                             ODStorageUnit* storageUnit);
  289.         
  290.     //----- Extensions    
  291.     void                            PrivSetExtensionManager(FW_CExtensionManager* manager);
  292.     
  293.     //----- Scripting    
  294.     void                            PrivSetSemanticInterface(FW_CSemanticInterface* semInt);
  295.  
  296. //----------------------------------------------------------------------------------------
  297. //    Data members
  298. //
  299. public:
  300.     static unsigned short        gSessionGlobalsCount;
  301.     
  302.     static ODTypeToken            gSelectionFocusToken;
  303.     static ODTypeToken            gMenuFocusToken;
  304.     static ODTypeToken            gKeyFocusToken;
  305.     static ODTypeToken            gModalFocusToken;
  306.     static ODTypeToken            gClipboardFocusToken;
  307.     static ODTypeToken            gScrollingFocusToken;
  308.     static ODTypeToken            gViewAsFrameToken;
  309.     static ODTypeToken            gViewAsSmallIconToken;
  310.     static ODTypeToken            gViewAsLargeIconToken;
  311.     static ODTypeToken            gViewAsThumbnailToken;
  312.     
  313. #ifdef FW_BUILD_MAC    
  314.     static ODType                gMacPICTDataType;
  315.     static ODType                gMacPICTFileType;
  316.     
  317.     static ODType                gMachfsDataType;
  318.     
  319.     static ODType                gMacTEXTDataType;
  320.     static ODType                gMacTEXTFileType;
  321.  
  322.     static ODType                gMacMooVFileType;
  323. #endif
  324.  
  325. private:
  326.     ODPart*                        fODPart;
  327.  
  328.     // [HLX] could be globals
  329.     FW_ResourceId                fPartInfoID;            // Part Info resource ID
  330.     FW_ResourceId                fViewAsIconID;            // Default View As Icon ID
  331.     ODValueType                    fPartKind;                // Part Kind
  332.     FW_CString                    fPartUserName;            // user name
  333.     
  334.     short                        fIdleCount;
  335.     short                        fModalDialogCount;    // number of nested modal dialogs
  336.  
  337.     FW_CMenuBar*                fMenuBar;            // This is the current menubar 
  338.     FW_CFrame*                     fLastActiveFrame;
  339.     FW_TOrderedCollection<FW_CPresentation>* fPresentations;    
  340.     FW_CPresentation*            fDefaultPresentation;
  341.     
  342.     FW_Instance                    fPartInstance;
  343.     FW_CIdler*                    fIdler;                // Idler object attached to the part (NULL if part not registered)
  344.     
  345.     FW_CLinkManager*            fLinkManager;        // NULL if Part doesn't create Links
  346.  
  347.     FW_CEventDispatcher*        fEventDispatcher;    // Event Dispatcher
  348.     
  349.     FW_CExtensionManager*        fExtensionManager;
  350.     
  351.     FW_CSemanticInterface*        fSemanticInterface;
  352.     
  353.     FW_CPrintInfo*                fPrintInfo;            // May be NULL
  354.  
  355.     FW_CContent*                fContent;
  356.     FW_CDataInterchange*        fDataInterchange;    
  357. };
  358.  
  359. //========================================================================================
  360. //    Inlines
  361. //========================================================================================
  362.  
  363. //----------------------------------------------------------------------------------------
  364. //    FW_CPart::GetEventDispatcher
  365. //----------------------------------------------------------------------------------------
  366. inline FW_CEventDispatcher* FW_CPart::GetEventDispatcher(Environment*) const
  367. {
  368.     return fEventDispatcher;
  369. }
  370.  
  371. //----------------------------------------------------------------------------------------
  372. //    FW_CPart::GetPartInstance
  373. //----------------------------------------------------------------------------------------
  374. inline FW_Instance FW_CPart::GetPartInstance(Environment*) const
  375. {
  376.     return fPartInstance;
  377. }
  378.  
  379. //----------------------------------------------------------------------------------------
  380. //    FW_CPart::GetViewAsIconID
  381. //----------------------------------------------------------------------------------------
  382. inline FW_ResourceId FW_CPart::GetViewAsIconID(Environment*) const
  383. {
  384.     return fViewAsIconID;
  385. }
  386.  
  387. //----------------------------------------------------------------------------------------
  388. //    FW_CPart::GetStorageUnit
  389. //----------------------------------------------------------------------------------------
  390. inline ODStorageUnit* FW_CPart::GetStorageUnit(Environment *ev) const
  391. {
  392.     return fODPart->GetStorageUnit(ev);
  393. }
  394.  
  395. //----------------------------------------------------------------------------------------
  396. //    FW_CPart::GetLastActiveFrame
  397. //----------------------------------------------------------------------------------------
  398. inline FW_CFrame* FW_CPart::GetLastActiveFrame(Environment*) const
  399. {
  400.     return fLastActiveFrame;
  401. }
  402.  
  403. //----------------------------------------------------------------------------------------
  404. //    FW_CPart::GetMenuBar
  405. //----------------------------------------------------------------------------------------
  406. inline FW_CMenuBar* FW_CPart::GetMenuBar(Environment*) const
  407. {
  408.     return fMenuBar;
  409. }
  410.  
  411. //---------------------------------------------------------------------------------------
  412. //    FW_CPart::GetPartKind
  413. //---------------------------------------------------------------------------------------
  414. inline ODValueType FW_CPart::GetPartKind(Environment*) const
  415. {
  416.     return  fPartKind;
  417. }
  418.  
  419. //----------------------------------------------------------------------------------------
  420. //    FW_CPart::GetODPart
  421. //----------------------------------------------------------------------------------------
  422. inline ODPart* FW_CPart::GetODPart(Environment*) const
  423. {
  424.     return fODPart;
  425. }
  426.  
  427. //----------------------------------------------------------------------------------------
  428. //    FW_CPart::PrivSetExtensionManager
  429. //----------------------------------------------------------------------------------------
  430. inline void FW_CPart::PrivSetExtensionManager(FW_CExtensionManager* manager)
  431. {
  432.     fExtensionManager = manager;
  433. }
  434.  
  435. //----------------------------------------------------------------------------------------
  436. //    FW_CPart::GetExtensionManager
  437. //----------------------------------------------------------------------------------------
  438. inline FW_CExtensionManager* FW_CPart::GetExtensionManager(Environment*) const
  439. {
  440.     return fExtensionManager;
  441. }
  442.  
  443. //---------------------------------------------------------------------------------------
  444. //    FW_CPart::GetLinkManager
  445. //----------------------------------------------------------------------------------------
  446. inline FW_CLinkManager* FW_CPart::GetLinkManager(Environment*) const
  447. {
  448.     return fLinkManager;
  449. }
  450.  
  451. //----------------------------------------------------------------------------------------
  452. //    FW_CPart::PrivSetSemanticInterface
  453. //----------------------------------------------------------------------------------------
  454. inline void FW_CPart::PrivSetSemanticInterface(FW_CSemanticInterface* semInt)
  455. {
  456.     fSemanticInterface = semInt;
  457. }
  458.  
  459. //----------------------------------------------------------------------------------------
  460. //    FW_CPart::GetSemanticInterface
  461. //----------------------------------------------------------------------------------------
  462. inline FW_CSemanticInterface* FW_CPart::GetSemanticInterface(Environment*) const
  463. {
  464.     return fSemanticInterface;
  465. }
  466.  
  467. //---------------------------------------------------------------------------------------
  468. //    FW_CPart::GetContent
  469. //----------------------------------------------------------------------------------------
  470. inline FW_CContent* FW_CPart::GetContent(Environment*) const
  471. {
  472.     return fContent;
  473. }
  474.  
  475. //---------------------------------------------------------------------------------------
  476. //    FW_CPart::GetDataInterchange
  477. //----------------------------------------------------------------------------------------
  478. inline FW_CDataInterchange* FW_CPart::GetDataInterchange(Environment*) const
  479. {
  480.     return fDataInterchange;
  481. }
  482.  
  483. //----------------------------------------------------------------------------------------
  484. //    FW_CPart::PrivSetLastActiveFrame
  485. //----------------------------------------------------------------------------------------
  486. inline void FW_CPart::PrivSetLastActiveFrame(FW_CFrame* lastActiveFrame)
  487. {
  488.     // this is the frame which takes the selection focus when the part is active
  489.     // (it is not set to NULL when the part becomes inactive)
  490.     fLastActiveFrame = lastActiveFrame;
  491. }
  492.  
  493.  
  494. #endif
  495.  
  496.  
  497.  
  498.